import { createRouter, createWebHistory } from "vue-router";

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      name: "layout",
      component: () => import("@/views/LayoutView.vue"),
      children: [
        {
          path: "/",
          name: "home",
          component: () => import("@/views/HomeView.vue"),
        },
        {
          path: "/category",
          name: "category",
          component: () => import("@/views/CategoryView.vue"),
        },
        {
          path: "/category/:id",
          name: "categoryItem",
          component: () => import("@/views/ItemView.vue"),
        },
        {
          path: "/product/:id",
          name: "product",
          component: () => import("@/views/ProductView.vue"),
        },
      ],
    },
    {
      path: "/:catchAll(.*)", // 匹配所有未定义的路径
      name: "notFound",
      component: () => import("@/views/NotFoundView.vue"), // 404页面
    },
  ],
});

export default router;
